package com.qiaoyanqing.textdemoqyq7.Fragments;



import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.qiaoyanqing.textdemoqyq7.Activities.MainActivity;
import com.qiaoyanqing.textdemoqyq7.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class WelconmeFragment extends Fragment implements View.OnClickListener {


    public WelconmeFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_welconme, container, false);
        Bundle bundle=getArguments();
        String index="slide1";
        if (bundle != null) {
            index=bundle.getString("index");
        }
        int id=getResources().getIdentifier(index,"drawable",getContext().getPackageName());
        ImageView showimage= (ImageView) view.findViewById(R.id.showimage);
        showimage.setImageResource(id);
        //当index是slide3的时候显示 imageview
        if ("slide3".equals(index)){
            ImageView start= (ImageView) view.findViewById(R.id.start);
            start.setVisibility(View.VISIBLE);
           start.setOnClickListener(this);

        }


        return view;

    }

    @Override
    public void onClick(View view) {
        Intent intent=new Intent(getContext(),MainActivity.class);
        startActivity(intent);

    }
}
